package org.nokatag.code;

import java.util.Iterator;
import java.util.Random;

public class RandomYBestFitTextRenderer extends AbstractTextRenderer
{

    public RandomYBestFitTextRenderer()
    {
    }

    protected void arrangeCharacters(int width, int height, TextString ts)
    {
        double widthRemaining = ((double)width - ts.getWidth() - (double)leftMargin - (double)rightMargin) / (double)ts.getCharacters().size();
        double vmiddle = height / 2;
        double x = (double)leftMargin + widthRemaining / 2D;
        Random r = new Random();
        height -= topMargin + bottomMargin;
        for(Iterator i$ = ts.getCharacters().iterator(); i$.hasNext();)
        {
            TextCharacter tc = (TextCharacter)i$.next();
            double heightRemaining = (double)height - tc.getHeight();
            double y = vmiddle + 0.34999999999999998D * tc.getAscent() + (1.0D - 2D * r.nextDouble()) * heightRemaining;
            tc.setX(x);
            tc.setY(y);
            x += tc.getWidth() + widthRemaining;
        }

    }
}

